Taken from a post by Aaron Patterson on the Ruby mailing list:

Here is what I made Set do:

  class Set
    def eql?(o)
      return false unless o.is_a?(Set)
      @hash.keys.sort_by { |x| x.hash }.
        eql?(o.instance_eval{@hash}.keys.sort_by { |x| x.hash })
    end

    def hash
      @hash.keys.sort_by { |x| x.hash }.hash
    end
  end

I don't particularly care what order the set is in, so I sorted by hash
and eql?'d on that.  It could probably be sped up by comparing lengths
of the keys, but I didn't really care.....
